/**
 * FileName: JobQuery
 * Author:   zhangyu84
 * Date:     2018/6/28 18:19
 * Description: job的相关查询条件
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.bj58.mis.apm.server.statistics.query.job;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 〈一句话功能简述〉<br> 
 * 〈job的相关查询条件〉
 *
 * @author zhangyu84
 * @create 2018/6/28
 * @since 1.0.0
 */
@Data
public class JobQuery {
    @ApiModelProperty(value = "项目")
    private String projectId;
    @ApiModelProperty(value = "cube")
    private String cubeId;
    @ApiModelProperty(value = "负责人OA账号")
    private String owner;
    @ApiModelProperty(value = "job状态")
    private String status;
    @ApiModelProperty(value = "查询project 或者cube的名称")
    private String cubeOrProjectQuery;
    @ApiModelProperty(value = "开始时间",required = true)
    private String startDate;
    @ApiModelProperty(value = "结束时间",required = true)
    private String endDate;
    @ApiModelProperty(value = "排序属性(cube:jobCube,项目:jobProject,耗时:jobTime,MR等待耗时:jobWaitTime,状态:jobStatus,开始时间:jobStartTime,结束时间:jobEndTime)")
    private String orderBy;
    @ApiModelProperty(value = "默认升序 升序:asc 降序:desc")
    private String  sort;

    public void setOrderBy(String orderBy) {
        switch (orderBy){
            case "jobCube":
                this.orderBy="kc.name";
                break;
            case "jobProject":
                this.orderBy="kp.name";
                break;
            case "jobTime":
                this.orderBy="kj.duration";
                break;
            case "jobWaitTime":
                this.orderBy="kj.mr_waiting";
                break;
            case "jobStatus":
                this.orderBy="kj.job_status";
                break;
            case "jobStartTime":
                this.orderBy="kj.exec_start_time";
                break;
            case "jobEndTime":
                this.orderBy="kj.exec_end_time";
                break;
                default:
                    this.orderBy=null;

        }
    }

    public void setSort(String sort) {
        String desc="desc",asc="asc";
        if(sort.toLowerCase().equals(desc) || sort.toLowerCase().equals(asc)){
            this.sort = sort;
        }else{
            this.sort = null;
        }
    }




}
